package com.study.sfd.person.controller;

import com.study.common.utils.R;
import com.study.common.utils.Result;
import com.study.common.entity.PatientEntity;
import com.study.sfd.person.service.PatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;



/**
 * patient(患者)
 *
 * @author 王个球
 * @email wangdajunzy@163.com
 * @date 2021-11-12 13:45:41
 */
@RestController
@RequestMapping("person/patient")
public class PatientController
{
    @Autowired
    private PatientService patientService;

    /**
     * 列表
     */
    @GetMapping()
    public Result<?> list()
    {
        List<PatientEntity> patients = patientService.listPatients();
        return Result.success(patients);
    }

    /**
     * 信息
     */
    @GetMapping("/{id}")
    public Result<?> info(@PathVariable("id") Integer id)
    {
		PatientEntity patient = patientService.getById(id);
        return Result.success(patient);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    // @RequiresPermissions("person:patient:save")
    public R save(@RequestBody PatientEntity patient){
		patientService.save(patient);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    // @RequiresPermissions("person:patient:update")
    public R update(@RequestBody PatientEntity patient){
		patientService.updateById(patient);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    // @RequiresPermissions("person:patient:delete")
    public R delete(@RequestBody Integer[] ids){
		patientService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
